#include <iostream>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include "../macro.h"

using std::cout;
using std::endl;

void fun()
{
    int fd = open("./test", O_RDWR);
    ERR_CHECK(fd, -1, "open")
    int ret = ftruncate(fd, 4096);
    ERR_CHECK(ret, -1, "ftruncate")

    char *p = (char *)mmap(NULL, 4096, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0);
    ERR_CHECK(p, (char *)-1, "mmap")

    printf("p=%x\n", p);
    while(1);
}

int main(int args, char *argv[])
{
    fun();
    return 0;
}